package com.hkbigdata.springbootmybatis.controller;

import com.hkbigdata.springbootmybatis.bean.Department;
import com.hkbigdata.springbootmybatis.mapper.DepartmentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liuanbo
 * @creat 2024-10-30-15:26
 * @see 2194550857@qq.com
 */
@RestController
public class DepartmentController {
    @Autowired
    DepartmentMapper departmentMapper;

    @GetMapping("/dept/{id}")
    public Department getDeptById(@PathVariable("id") Integer id) {
        Department departmentById = departmentMapper.getDepartmentById(id);
        return departmentById;
    }

    @GetMapping("/dept/insert")
    public int insertDept(Department department) {
        int i = departmentMapper.addDepartment(department);
        return i;
    }

    @GetMapping("/dept/update")
    public int updateDept(Department department) {
        int i = departmentMapper.updateDepartment(department);
        return i;
    }

    @GetMapping("/dept/delete/{id}")
    public int deleteDept(@PathVariable("id") Integer id) {
        int i = departmentMapper.deleteDepartmentById(id);
        return i;
    }

}
